package com.heima.admin.controller.v1;

import com.heima.admin.service.WemediaNewsAutoScanService;
import com.heima.api.admin.NewsAuthControllerApi;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.media.dtos.NewAuthDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Title: TODO
 * @Description: TODO
 * @author: 丁丁
 * @date: 2021/3/22
 * @version:
 */
@RestController
@RequestMapping("/api/v1/news_auth")
public class NewsAuthController implements NewsAuthControllerApi {
    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    /**
     * 查询自媒体文章列表
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/list")
    public ResponseResult findNews(@RequestBody NewAuthDto dto) {
        return wemediaNewsAutoScanService.findNews(dto);
    }

    /**
     * 查询文章详情
     *
     * @param id
     * @return
     */
    @Override
    @GetMapping("/one/{id}")
    public ResponseResult findOne(@PathVariable("id") Integer id) {
        return wemediaNewsAutoScanService.findOne(id);
    }

    /**
     * 文章审核成功
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewAuthDto dto) {
        return wemediaNewsAutoScanService.updateStatus(1, dto);
    }

    /**
     * 文章审核失败
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewAuthDto dto) {
        return wemediaNewsAutoScanService.updateStatus(0, dto);
    }
}
